<?php 
class TplStyleController extends Controller{
	public function __init(){

	}

	public function index(){
		$dirs=Dir::tree('Template');
		foreach ($dirs as $id => $d) {
			if(!is_file($d['path'].'pre.jpg') || !is_file($d['path'].'config.xml')){
				continue;
			}
			$dirs[$id]['current']=$d['filename']==C('webstyle')?1:0;
			$dirs[$id]['image']=__ROOT__.'/Template/'.$d['filename'].'/pre.jpg';
			$dirs[$id]['config']=Xml::toArray(file_get_contents($d['path'].'config.xml'));
			// p($dirs);exit;
		}
		$this->assign('dirs',$dirs);
		$this->display();
	}

	public function set(){
		$db=K('Config');
		if($db->setTplSTyle()){
			$this->success('模版设置成功');
		}else{
			$this->error($db->error);
		}
	}
}

?>